<!--


Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->

<div class="row">
    <div class="col-sm-8 col-md-8">
        <h3>{{title}}</h3>
    </div>
    <div class="col-sm-4 col-md-4">
        <button type="button" class="edit-user-btn btn action-btn" ng-disabled="userForm.$pristine || userForm.$invalid" ng-click="confirmUpdate(userData, userForm.username)">Update</button>
        <button type="button" class="edit-user-btn btn btn-link"  ng-click="resetUser()">Reset</button>
    </div>
</div>

<hr>

<form class="register-form col-sm-8 col-md-8" name="userForm" role="form" novalidate>

    <fieldset>

        <legend>User Details</legend>

        <div class="row">
            <div class="col-sm-6 col-md-6">
                <div class="form-group" ng-class="{'has-error': hasError(userForm.fullName), 'has-feedback': hasError(userForm.fullName)}">
                    <label class="control-label" for="fullName">Full Name
                        <small ng-show="hasPropertyError(userForm.fullName, 'required')">[ Required ]</small>
                        <small ng-show="hasPropertyError(userForm.fullName, 'maxlength')">[ Too Long ]</small>
                    </label>
                    <input id="fullName" name="fullName" type="text" class="form-control" ng-model="userData.fullName" ng-maxlength="256" autofocus required>
                    <span ng-show="hasError(userForm.fullName)" class="form-control-feedback"><i class="fa fa-times"></i></span>
                </div>
            </div>
            <div class="col-sm-6 col-md-6">
                <div class="form-group" ng-class="{'has-error': hasError(userForm.company), 'has-feedback': hasError(userForm.company)}">
                    <label class="control-label" for="company">Company (optional)
                        <small ng-show="hasPropertyError(userForm.company, 'maxlength')">[ Too Long ]</small>
                    </label>
                    <input id="company" name="company" type="text" class="form-control" ng-model="userData.company" ng-maxlength="256">
                    <span ng-show="hasError(userForm.company)" class="form-control-feedback"><i class="fa fa-times"></i></span>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-6 col-md-6">
                <div class="form-group" ng-class="{'has-error': hasError(userForm.email), 'has-feedback': hasError(userForm.email)}">
                    <label class="control-label" for="email">Email
                        <small ng-show="hasPropertyError(userForm.email, 'required')">[ Required ]</small>
                        <small ng-show="hasPropertyError(userForm.email, 'maxlength')">[ Too Long ]</small>
                    </label>
                    <input id="email" name="email" type="email" class="form-control" ng-model="userData.email" ng-maxlength="128" required>
                    <span ng-show="hasError(userForm.email)" class="form-control-feedback"><i class="fa fa-times"></i></span>
                </div>
            </div>
            <div class="col-sm-6 col-md-6">
                <div class="form-group" ng-class="{'has-error': hasError(userForm.username), 'has-feedback': hasError(userForm.username)}">
                    <label class="control-label" for="userName">Username
                        <small ng-show="hasPropertyError(userForm.username, 'required')">[ Required ]</small>
                        <small ng-show="hasPropertyError(userForm.username, 'maxlength')">[ Too Long ]</small>
                    </label>
                    <input id="username" name="username" type="text" class="form-control" ng-model="userData.username" ng-maxlength="128" required>
                    <span ng-show="hasError(userForm.username)" class="form-control-feedback"><i class="fa fa-times"></i></span>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-6 col-md-6">
                <div class="form-group" ng-class="{'has-error': hasError(userForm.password), 'has-feedback': hasError(userForm.password)}">
                    <label class="control-label" for="password">New Password <span ng-show="!registration && !reset">(optional)</span>
                        <small ng-show="hasPropertyError(userForm.password, 'minlength')">[ Too Short ]</small>
                    </label>
                    <input id="password" name="password" type="password" class="form-control" ng-model="userData.localPasswd" ng-required="registration || reset" ng-minlength="6">
                    <span ng-show="hasError(userForm.password)" class="form-control-feedback"><i class="fa fa-times"></i></span>
                </div>
            </div>
            <div class="col-sm-6 col-md-6">
                <div class="form-group" ng-class="{'has-error': hasError(userForm.confirmPassword), 'has-feedback': hasError(userForm.confirmPassword)}">
                    <label class="control-label" for="confirmPassword">Confirm New Password <span ng-show="!registration && !reset && !userData.localPasswd">(optional)</span>
                        <small ng-show="hasPropertyError(userForm.confirmPassword, 'match')">[ Doesn't Match ]</small>
                    </label>
                    <input id="confirmPassword" name="confirmPassword" type="password" class="form-control" ng-model="userData.confirmLocalPasswd" match="userData.localPasswd">
                    <span ng-show="hasError(userForm.confirmPassword)" class="form-control-feedback"><i class="fa fa-times"></i></span>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-12 col-md-12">
                <div class="form-group" ng-class="{'has-error': hasError(userForm.addressLine1), 'has-feedback': hasError(userForm.addressLine1)}">
                    <label class="control-label" for="addressLine1">Address Line 1 (optional)
                        <small ng-show="hasPropertyError(userForm.addressLine1, 'maxlength')">[ Too Long ]</small>
                    </label>
                    <input id="addressLine1" name="addressLine1" type="text" class="form-control" ng-model="userData.addressLine1" ng-maxlength="256">
                    <span ng-show="hasError(userForm.addressLine1)" class="form-control-feedback"><i class="fa fa-times"></i></span>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-12 col-md-12">
                <div class="form-group" ng-class="{'has-error': hasError(userForm.addressLine2), 'has-feedback': hasError(userForm.addressLine2)}">
                    <label class="control-label" for="addressLine2">Address Line 2 (optional)
                        <small ng-show="hasPropertyError(userForm.addressLine2, 'maxlength')">[ Too Long ]</small>
                    </label>
                    <input id="addressLine2" name="addressLine2" type="text" class="form-control" ng-model="userData.addressLine2" ng-maxlength="256">
                    <span ng-show="hasError(userForm.addressLine2)" class="form-control-feedback"><i class="fa fa-times"></i></span>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-12 col-md-12">
                <div class="form-group" ng-class="{'has-error': hasError(userForm.city), 'has-feedback': hasError(userForm.city)}">
                    <label class="control-label" for="city">City (optional)
                        <small ng-show="hasPropertyError(userForm.city, 'maxlength')">[ Too Long ]</small>
                    </label>
                    <input id="city" name="city" type="text" class="form-control" ng-model="userData.city" ng-maxlength="128">
                    <span ng-show="hasError(userForm.city)" class="form-control-feedback"><i class="fa fa-times"></i></span>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-6 col-md-6">
                <div class="form-group" ng-class="{'has-error': hasError(userForm.stateOrProvince), 'has-feedback': hasError(userForm.stateOrProvince)}">
                    <label class="control-label" for="stateOrProvince">State or Province (optional)
                        <small ng-show="hasPropertyError(userForm.stateOrProvince, 'maxlength')">[ Too Long ]</small>
                    </label>
                    <input id="stateOrProvince" name="stateOrProvince" type="text" class="form-control" ng-model="userData.stateOrProvince" ng-maxlength="128">
                    <span ng-show="hasError(userForm.stateOrProvince)" class="form-control-feedback"><i class="fa fa-times"></i></span>
                </div>
            </div>
            <div class="col-sm-6 col-md-6">
                <div class="form-group" ng-class="{'has-error': hasError(userForm.postalCode), 'has-feedback': hasError(userForm.postalCode)}">
                    <label class="control-label" for="postalCode">Postal Code (optional)
                        <small ng-show="hasPropertyError(userForm.postalCode, 'maxlength')">[ Too Long ]</small>
                    </label>
                    <input id="postalCode" name="postalCode" type="text" class="form-control" ng-model="userData.postalCode" ng-maxlength="11">
                    <span ng-show="hasError(userForm.postalCode)" class="form-control-feedback"><i class="fa fa-times"></i></span>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-6 col-md-6">
                <div class="form-group" ng-class="{'has-error': hasError(userForm.country), 'has-feedback': hasError(userForm.country)}">
                    <label class="control-label" for="country">Country (optional)
                        <small ng-show="hasPropertyError(userForm.country, 'maxlength')">[ Too Long ]</small>
                    </label>
                    <input id="country" name="country" type="text" class="form-control" ng-model="userData.country" ng-maxlength="256">
                    <span ng-show="hasError(userForm.country)" class="form-control-feedback"><i class="fa fa-times"></i></span>
                </div>
            </div>
            <div class="col-sm-6 col-md-6">
                <div class="form-group" ng-class="{'has-error': hasError(userForm.phoneNumber), 'has-feedback': hasError(userForm.phoneNumber)}">
                    <label class="control-label" for="phoneNumber">Primary Phone (optional)
                        <small ng-show="hasPropertyError(userForm.phoneNumber, 'maxlength')">[ Too Long ]</small>
                    </label>
                    <input id="phoneNumber" name="phoneNumber" type="text" class="form-control" ng-model="userData.phoneNumber" ng-maxlength="25">
                    <span ng-show="hasError(userForm.phoneNumber)" class="form-control-feedback"><i class="fa fa-times"></i></span>
                </div>
            </div>
        </div>

    </fieldset>

</form>